import request from '@/utils/request'

// 地址组

// 地址组对象删除
export function delAddrGroupData (params) {
  var data = fromData(params)
  return request({
    url: '/addr_group/del_addr_group',
    method: 'post',
    data
  })
}

// 地址组对象查看
export function getAddrGroupInfo (params) {
  var data = fromData(params)
  return request({
    url: '/addr_group/getAddrGroupInfo',
    method: 'post',
    data
  })
}

// 增加地址组对象
export function addAddrGroup (params) {
  var data = fromData(params)
  return request({
    url: '/addr_group/addAddrGroup',
    method: 'post',
    data
  })
}

// 获取地址组对象列表
export function getAddrGroupArray (params) {
  var data = fromData(params)
  return request({
    url: '/addr_group/getAddrGroupArray',
    method: 'post',
    data
  })
}

// 编辑地址组对象
export function editAddrGroup (params) {
  var data = fromData(params)
  return request({
    url: '/addr_group/editAddrGroup',
    method: 'post',
    data
  })
}

function fromData (params) {
  let formData = new FormData()
  for (const it in params) {
    if (!Object.is(params[it], null) && !Object.is(params[it], '')) {
      formData.append(it, params[it])
    }
  }
  return formData
}
